/**
 * 
 */
package demo.tellurium.test.cqp;

import java.util.Date;

import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

import demo.tellurium.framework.BaseTelluriumJUnitTestCase;
import demo.tellurium.module.cqp.CQPLoginModule;
import demo.tellurium.module.cqp.CQPProfileModule;

/**
 * @author roger.xu
 * 
 */
public class CreateSTGAssessmentJUnitTestCase extends BaseTelluriumJUnitTestCase {
    private static CQPLoginModule cqpLogin;
    private static CQPProfileModule cqpProfile;

    private static final int OFFERING_TYPE_STG_OPTION_INDEX = 2;

    @BeforeClass
    public static void initUi() {
        cqpLogin = new CQPLoginModule();
        cqpLogin.defineUi();

        cqpProfile = new CQPProfileModule();
        cqpProfile.defineUi();
    }

    @Test
    public void connectTo() {
        String contextUrl = getProperty("cqp.context.url");
        String pagePath = getProperty(CQPProfileModule.PATH_KEY);
        String url = String.format("%s/%s", contextUrl, pagePath);
        connectUrl(url);
    }

    @Test
    public void testLogin() {
        console.debug("[testLogin]");
        cqpLogin.doAdminLogin();
        pauseSec(3);
    }

    @Test
    public void testOfferingType() {
        console.debug("[testOfferingType]");
        cqpProfile.doSelectOfferingType(OFFERING_TYPE_STG_OPTION_INDEX);
    }

    @Test
    public void testDivision() {
        console.debug("[testDivision]");
        cqpProfile.doSelectDivision(1);
    }

    @Test
    public void testProductName() {
        console.debug("[testProductName]");
        String productName = String.format("stg test - %s", RandomStringUtils.randomAlphanumeric(8));
        cqpProfile.doInputProductName(productName);
    }

    @Test
    public void testVRMF() {
        console.debug("[testVRMF]");
        cqpProfile.doInputVRMF("1.0.0");
    }

    @Test
    public void testProductType() {
        console.debug("[testProductType]");
        cqpProfile.doSelectProductType(1);
    }

    @Test
    public void testPlatform() {
        console.debug("[testPlatform]");
        cqpProfile.doSelectPlatform(1);
    }

    @Test
    public void testPhase() {
        console.debug("[testPhase]");
        cqpProfile.doSelectPhase(1);
    }

    @Test
    public void testRole() {
        console.debug("[testRole]");
        cqpProfile.doSelectRole(1);
    }

    @Ignore
    @Test
    public void testDocumentName() {
        console.debug("[testDocumentName]");
        cqpProfile.doInputDocumentName("roger test");
    }

    @Test
    public void testDescription() {
        console.debug("[testDescription]");
        Date date = new Date();
        String dateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(date);
        String mark = String.format("[test save][%s]", dateStr);
        cqpProfile.doInputDescription(mark);
    }

    @Test
    public void testSave() {
        console.debug("[testSave]");
        cqpProfile.doClickSaveButton();
        pauseSec(5);
        // manualBreak();
    }

}
